/*
 * The Open Source Unix Installer
 *
 * The MIT License
 *
 * Copyright 2011-2012 Andrey Pudov.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

/*
 * @author  Andrey Pudov    <andrey@andreypudov.com>
 * @version 0.00.00
 * @name    control_panel.h
 * @date:   Jan 16, 2012
 */

#include "control_panel.h"

ControlPanel* installer_control_panel_new() {
    ControlPanel *panel = (ControlPanel*)malloc(sizeof(ControlPanel));
    if (panel == NULL) {
        //TODO Add Logger
        exit(EXIT_FAILURE);
    }

    panel->horizontal_box = gtk_hbox_new(FALSE, 0);
    panel->horizontal_align = gtk_alignment_new(1, 0, 0, 0); /* 1 (right), 0 (top), without filling the space */

    panel->back_button = gtk_button_new_with_label("Back");
    panel->next_button = gtk_button_new_with_label("Next");
    panel->cancel_button = gtk_button_new_with_label("Cancel");

    gtk_container_add(GTK_CONTAINER(panel->horizontal_box), panel->back_button);
    gtk_container_add(GTK_CONTAINER(panel->horizontal_box), panel->next_button);
    gtk_container_add(GTK_CONTAINER(panel->horizontal_box), panel->cancel_button);

    gtk_container_add(GTK_CONTAINER(panel->horizontal_align), panel->horizontal_box);

    return panel;
}

void installer_control_panel_delete(ControlPanel *panel) {
    free(panel);
}

GtkWidget* installer_control_panel_get_container(ControlPanel *panel) {
    return panel->horizontal_align;
}

void installer_control_panel_back_button_set_enabled(ControlPanel *panel, bool enabled) {
    gtk_widget_set_sensitive(GTK_WIDGET(panel->back_button), enabled);
}

void installer_control_panel_next_button_set_enabled(ControlPanel *panel, bool enabled) {
    gtk_widget_set_sensitive(GTK_WIDGET(panel->next_button), enabled);
}

void installer_control_panel_cancel_button_set_enabled(ControlPanel *panel, bool enabled) {
    gtk_widget_set_sensitive(GTK_WIDGET(panel->cancel_button), enabled);
}
